﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="三分厂半成品收发存表.aspx.cs" Inherits="syc.ChengBen.三分厂.三分厂半成品收发存表" %>
<%@ Import  Namespace="System.Data"%>
<%@ Import  Namespace="System.Data.SqlClient"%>
<%@ Import  Namespace="System.Configuration"%>
<%@ Import  Namespace="NPOI.HSSF.UserModel"%>
<%@ Import  Namespace="NPOI.HPSF"%>
<%@ Import  Namespace="System.IO"%>

<html>
<head runat="server">
    <title></title>
</head>
<body>
<script runat =server>
    protected HSSFWorkbook hssfworkbook;
    protected int part1Count;
    protected int part2Count;
    protected int part3Count;
    protected int part4Count;
    protected double 合计;

    protected double 套管单位费用合计;

    protected double 油管单位费用合计;

    protected double 套管累计单位费用合计;

    protected double 油管累计单位费用合计;
    
    protected double 套管接箍产量;
    protected double 油管接箍产量;

    protected double 套管接箍回收金额;
    protected double 油管接箍回收金额;
    protected double 套管接箍费用;
    protected double 油管接箍费用;
    protected double 套管接箍成本;
    protected double 油管接箍成本;

    protected double 套管接箍累计产量;
    protected double 油管接箍累计产量;

    protected double 套管接箍累计回收金额;
    protected double 油管接箍累计回收金额;
    protected double 套管接箍累计费用;
    protected double 油管接箍累计费用;
    protected double 套管接箍累计成本;
    protected double 油管接箍累计成本;
    //本期入库  
    protected double 套管接箍本期入库重量;
    protected double 油管接箍本期入库重量;
    protected double 套管接箍本期入库金额;
    protected double 油管接箍本期入库金额;
    //本期出库
    protected double 套管接箍本期转一分厂出库支数;
    protected double 套管接箍本期转一分厂出库重量;
    protected double 套管接箍本期转一分厂出库金额;

    protected double 套管接箍本期转二分厂出库支数;
    protected double 套管接箍本期转二分厂出库重量;
    protected double 套管接箍本期转二分厂出库金额;
    
    protected double 油管接箍本期转二分厂出库支数;
    protected double 油管接箍本期转二分厂出库重量;
    protected double 油管接箍本期转二分厂出库金额;
    
    protected double 油管接箍本期转五分厂出库支数;
    protected double 油管接箍本期转五分厂出库重量;
    protected double 油管接箍本期转五分厂出库金额;

    //原料投入来源材料收发存表
    //上期结存
    protected double 套管接箍光管上期结存数量;
    protected double 套管接箍光管上期结存金额;

    protected double 油管接箍光管上期结存数量;
    protected double 油管接箍光管上期结存金额;
    //本期收入      
    protected double 套管接箍光管本期收入数量;
    protected double 套管接箍光管本期收入金额;
    protected double 套管接箍光管本期累计收入数量;
    protected double 套管接箍光管本期累计收入金额;

    protected double 油管接箍光管本期收入数量;
    protected double 油管接箍光管本期收入金额;
    protected double 油管接箍光管本期累计收入数量;
    protected double 油管接箍光管本期累计收入金额;

    //本期发出
    protected double 套管接箍投入数量;
    protected double 套管接箍投入金额;
    protected double 油管接箍投入数量;
    protected double 油管接箍投入金额;

    protected double 套管接箍累计投入数量;
    protected double 套管接箍累计投入金额;
    protected double 油管接箍累计投入数量;
    protected double 油管接箍累计投入金额;


    //本期结存支数
    protected double 套管接箍磷化支数;
    protected double 套管接箍半成品支数;
    protected double 套管接箍光管本期结存支数;

    protected double 油管接箍磷化支数;
    protected double 油管接箍半成品支数;
    protected double 油管接箍光管本期结存支数;

    protected double 套管接箍光管本期结存数量;
    protected double 油管接箍光管本期结存数量;

    protected double 套管接箍光管本期结存金额;
    protected double 油管接箍光管本期结存金额;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
             Button_Query_Click(null, null);
            this.Year.SelectedValue = DateTime.Today.Year.ToString();
            this.Month.SelectedValue = DateTime.Today.Month.ToString();
        }
    }
    protected void Button_Query_Click(object sender, EventArgs e)
    {
        SqlConnection Conn = new SqlConnection();
        Conn.ConnectionString = ConfigurationManager.ConnectionStrings["SCMConnectionString1"].ConnectionString;
        Conn.Open();
        SqlCommand Cmd = new SqlCommand();
        Cmd.Connection = Conn;
          string sql="";
               DataSet ds = new DataSet();
               string sqlpartCount = @"
               select 财务处.value('count(/root/rnode[1]/*)','int') from test where 分厂=3 and year=@年度 and month=@月份
               select 财务处.value('count(/root/rnode[2]/*)','int') from test where 分厂=3 and year=@年度 and month=@月份
               select 财务处.value('count(/root/rnode[3]/*)','int') from test where 分厂=3 and year=@年度 and month=@月份
               select 财务处.value('count(/root/rnode[4]/*)','int') from test where 分厂=3 and year=@年度 and month=@月份";
               sqlpartCount = sqlpartCount.Replace("@年度", this.Year.Text);
               sqlpartCount = sqlpartCount.Replace("@月份", this.Month.Text);
               SqlDataAdapter sda = new SqlDataAdapter(sqlpartCount, Conn);
               sda.Fill(ds);
               DataTable dt1 = ds.Tables[0];
               DataTable dt2 = ds.Tables[1];
               DataTable dt3 = ds.Tables[2];
               DataTable dt4 = ds.Tables[3];
               try
               {
                   part1Count = int.Parse(dt1.Rows[0][0].ToString());

                   part2Count = int.Parse(dt2.Rows[0][0].ToString());

                   part3Count = int.Parse(dt3.Rows[0][0].ToString());

                   part4Count = int.Parse(dt4.Rows[0][0].ToString());
               }
               catch
               {
                   part1Count = 0;

                   part2Count = 0;

                   part3Count = 0;

                   part4Count = 0;
               }
                //part1
                string str1 = @"
        select '一、'+财务处.value('(/root/rnode/@name)[1]','nvarchar(10)')
        ,财务处.value('(/root/rnode/@cash)[1]','float')
        ,round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,财务处.value('(/root/rnode/@cash)[1]','float') as 合计
        ,round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[1]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,TJ55
        ,(select isnull(sum(TJ55),0) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,YJ55
        ,(select isnull(sum(YJ55),0) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        from test where year=@年度 and  分厂=3 and month=@月份 ";
                string sql1 = "";
                for (int i = 0; i < part1Count; i++)
                {
                    sql1 += @"union all
                  select 财务处.value('(/root/rnode[1]/node/@name)[@i]','nvarchar(10)')
        ,财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')
        ,round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),@月份)/TJ55,@月份)
        ,(select sum(round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[1]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,0 as 合计
        ,0 
        ,0
        ,0
        ,0
        ,0 
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        from test where year=@年度 and  分厂=3 and month=@月份 
                     ";
                    sql1 = sql1.Replace("@i", (i + 1).ToString());
                }
                //part2
                string str2 = @"union all select '二、'+财务处.value('(/root/rnode/@name)[2]','nvarchar(10)')
        ,财务处.value('(/root/rnode/@cash)[2]','float')
        ,round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,财务处.value('(/root/rnode/@cash)[2]','float') as 合计
        ,round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[2]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,0
        ,0
        ,0
        ,0
        from test where year=@年度 and  分厂=3 and month=@月份 ";
                string sql2 = "";
                for (int i = 0; i < part2Count; i++)
                {
                    sql2 += @"union all
                  select 财务处.value('(/root/rnode[2]/node/@name)[@i]','nvarchar(10)')
        ,财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')
        ,round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[2]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,0 as 合计
        ,0 
        ,0
        ,0
        ,0
        ,0 
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        from test where year=@年度 and  分厂=3 and month=@月份 
                     ";
                    sql2 = sql2.Replace("@i", (i + 1).ToString());
                }
                string str3 = @"union all select '三、'+财务处.value('(/root/rnode/@name)[3]','nvarchar(10)')
        ,财务处.value('(/root/rnode/@cash)[3]','float')
        ,round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,财务处.value('(/root/rnode/@cash)[3]','float') as 合计
        ,round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[3]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,0
        ,0
        ,0
        ,0
        from test where year=@年度 and  分厂=3 and month=@月份 ";
                string sql3 = "";
                for (int i = 0; i < part3Count; i++)
                {
                    sql3 += @"union all
                  select 财务处.value('(/root/rnode[3]/node/@name)[@i]','nvarchar(10)')
        ,财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')
        ,round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[3]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,0 as 合计
        ,0 
        ,0
        ,0
        ,0
        ,0 
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        from test where year=@年度 and  分厂=3 and month=@月份 
                     ";
                    sql3 = sql3.Replace("@i", (i + 1).ToString());
                }
                string str4 = @"union all select '四、'+财务处.value('(/root/rnode/@name)[4]','nvarchar(10)')
        ,财务处.value('(/root/rnode/@cash)[4]','float')
        ,round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,财务处.value('(/root/rnode/@cash)[4]','float') as 合计
        ,round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)
        ,round((select sum(round(财务处.value('(/root/rnode/@cash)[4]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,0
        ,0
        ,0
        ,0
        from test where year=@年度 and  分厂=3 and month=@月份 ";
                string sql4 = "";
                for (int i = 0; i < part4Count; i++)
                {
                    sql4 += @"union all
                  select 财务处.value('(/root/rnode[4]/node/@name)[@i]','nvarchar(10)')
        ,财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')
        ,round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)/TJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(TJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(TJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)
        ,round(round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)/YJ55,2)
        ,(select sum(round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份) 
        ,round((select sum(round(财务处.value('(/root/rnode[4]/node/@cash)[@i]','float')*(YJ55/(TJ55+YJ55)),2)) from test where year=@年度 and  分厂=3 and month between 1 and @月份)/(select sum(YJ55) from test where year=@年度 and  分厂=3 and month between 1 and @月份),2)
        ,0 as 合计
        ,0 
        ,0
        ,0
        ,0
        ,0 
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        ,0
        from test where year=@年度 and  分厂=3 and month=@月份 
             ";
            sql4 = sql4.Replace("@i", (i + 1).ToString());
        }
        sql = str1 + sql1 + str2 + sql2 + str3 + sql3 + str4 + sql4;
        sql = sql.Replace("@年度", this.Year.Text);
        sql = sql.Replace("@月份", this.Month.Text);
         Cmd.CommandText = sql;
           
            SqlDataReader Reader = Cmd.ExecuteReader();
                           
                while (Reader.Read())
                    {
                        合计 += double.Parse(Reader[10].ToString());
                        套管接箍费用 += double.Parse(Reader[11].ToString());
                        套管单位费用合计 += double.Parse(Reader[12].ToString());
                        套管接箍累计费用 += double.Parse(Reader[13].ToString());
                        套管累计单位费用合计 += double.Parse(Reader[14].ToString());
                        油管接箍费用 += double.Parse(Reader[15].ToString());
                        油管单位费用合计 += double.Parse(Reader[16].ToString());
                        油管接箍累计费用 += double.Parse(Reader[17].ToString());
                        油管累计单位费用合计 += double.Parse(Reader[18].ToString());

                        套管接箍产量 += double.Parse(Reader[19].ToString());
                        套管接箍累计产量 += double.Parse(Reader[20].ToString());
                        油管接箍产量 += double.Parse(Reader[21].ToString());
                        油管接箍累计产量 += double.Parse(Reader[22].ToString());
                     }
                Reader.Close();         
           
             
           string sql5 = @"
                declare @套管接箍光管上期结存数量 float
                declare @套管接箍光管上期结存金额 float
                declare @油管接箍光管上期结存数量 float
                declare @油管接箍光管上期结存金额 float                
                
                declare @套管接箍光管本期收入数量 float
                declare @套管接箍光管本期收入金额 float                
                declare @油管接箍光管本期收入数量 float
                declare @油管接箍光管本期收入金额 float 
                declare @套管接箍光管本期累计收入数量 float
                declare @套管接箍光管本期累计收入金额 float                
                declare @油管接箍光管本期累计收入数量 float
                declare @油管接箍光管本期累计收入金额 float               
                          
                declare @套管磷化支数 float
                declare @套管半成品支数  float                
                declare @油管磷化支数  float
                declare @油管半成品支数  float   
                
                declare @套管接箍光管本期结存金额 float
                declare @油管接箍光管本期结存金额 float                
                
             
                
                select @油管接箍光管上期结存数量=结存支数*0.0032,@油管接箍光管上期结存金额=(本期收入金额/本期收入数量)*@油管接箍光管上期结存数量 from  三分厂原料收发存表 where 年度=@上年度 and 月份=@上月份 and 原料类别ID=1                    
                select @套管接箍光管上期结存数量=结存支数*0.01,@套管接箍光管上期结存金额=(本期收入金额/本期收入数量)*@套管接箍光管上期结存数量 from  三分厂原料收发存表 where 年度=@上年度 and 月份=@上月份 and 原料类别ID=2         
                
                select @油管接箍光管本期收入数量=本期收入数量,@油管接箍光管本期收入金额=本期收入金额 from  三分厂原料收发存表 where 年度=@年度 and 月份=@月份 and 原料类别ID=1                                        
                select @套管接箍光管本期收入数量=本期收入数量,@套管接箍光管本期收入金额=本期收入金额 from  三分厂原料收发存表 where 年度=@年度 and 月份=@月份 and 原料类别ID=2
                select @油管接箍光管本期累计收入数量=isnull(sum(本期收入数量),0),@油管接箍光管本期累计收入金额=isnull(sum(本期收入金额),0) from  三分厂原料收发存表 where 年度=@年度 and 月份 between 1 and @月份 and 原料类别ID=1                 
                select @套管接箍光管本期累计收入数量=isnull(sum(本期收入数量),0),@套管接箍光管本期累计收入金额=isnull(sum(本期收入金额),0) from 三分厂原料收发存表 where 年度=@年度 and 月份 between 1 and @月份 and 原料类别ID=2                      
                                
                select   @油管磷化支数 =本期已磷化支数,@油管半成品支数 =本期半成品支数 from  三分厂原料收发存表  where 年度=@年度 and 月份=@月份 and 原料类别ID=1    
                select   @套管磷化支数 =本期已磷化支数,@套管半成品支数 =本期半成品支数 from  三分厂原料收发存表  where 年度=@年度 and 月份=@月份 and 原料类别ID=2 
                       
                select  isnull(@套管接箍光管上期结存数量,0),isnull(@套管接箍光管上期结存金额,0)   
                        ,isnull(@油管接箍光管上期结存数量,0),isnull(@油管接箍光管上期结存金额,0)
                        ,isnull(@套管接箍光管本期收入数量,0),isnull(@套管接箍光管本期收入金额,0),isnull(@套管接箍光管本期累计收入数量,0),isnull(@套管接箍光管本期累计收入金额,0)
                        ,isnull(@油管接箍光管本期收入数量,0),isnull(@油管接箍光管本期收入金额,0),isnull(@油管接箍光管本期累计收入数量,0),isnull(@油管接箍光管本期累计收入金额,0)
                        ,isnull(@套管磷化支数,0),isnull(@套管半成品支数,0)
                        ,isnull(@油管磷化支数,0),isnull(@油管半成品支数,0)                                                                                                                                                                                                                                    
        ";

        sql5 = sql5.Replace("@年度", this.Year.Text);
        sql5= sql5.Replace("@月份", this.Month.Text);
        if ((int.Parse(this.Month.Text) - 1) == 0)
        {
            sql5 = sql5.Replace("@上年度", (int.Parse(this.Year.Text) - 1).ToString());
            sql5 = sql5.Replace("@上月份", "12");
        }
        else
        {
            sql5 = sql5.Replace("@上年度", (int.Parse(this.Year.Text)).ToString());
            sql5 = sql5.Replace("@上月份", (int.Parse(this.Month.Text) - 1).ToString());
        }

        Cmd.CommandText = sql5;
        Reader = Cmd.ExecuteReader();

        if (Reader.Read())
        {
            //上期结存
            套管接箍光管上期结存数量 = double.Parse(Reader[0].ToString());
            套管接箍光管上期结存金额 = double.Parse(Reader[1].ToString());
            油管接箍光管上期结存数量 = double.Parse(Reader[2].ToString());
            油管接箍光管上期结存金额 = double.Parse(Reader[3].ToString());
            //本期收入
            套管接箍光管本期收入数量 = double.Parse(Reader[4].ToString());
            套管接箍光管本期收入金额 = double.Parse(Reader[5].ToString()); ;
            套管接箍光管本期累计收入数量 = double.Parse(Reader[6].ToString());
            套管接箍光管本期累计收入金额 = double.Parse(Reader[7].ToString());

            油管接箍光管本期收入数量 = double.Parse(Reader[8].ToString());
            油管接箍光管本期收入金额 = double.Parse(Reader[9].ToString()); ;
            油管接箍光管本期累计收入数量 = double.Parse(Reader[10].ToString());
            油管接箍光管本期累计收入金额 = double.Parse(Reader[11].ToString());
            //本期结存
            套管接箍磷化支数 = double.Parse(Reader[12].ToString());
            套管接箍半成品支数 = double.Parse(Reader[13].ToString());
            油管接箍磷化支数 = double.Parse(Reader[14].ToString());
            油管接箍半成品支数 = double.Parse(Reader[15].ToString());

            套管接箍光管本期结存支数 = (套管接箍磷化支数 + 套管接箍半成品支数);
            油管接箍光管本期结存支数 = (油管接箍磷化支数 + 油管接箍半成品支数);

            套管接箍光管本期结存数量 = double.Parse((套管接箍光管本期结存支数 * 10 / 1000).ToString("0.000"));
            油管接箍光管本期结存数量 = double.Parse((油管接箍光管本期结存支数 * 3.2 / 1000).ToString("0.000"));
            double f1 = 套管接箍光管本期收入金额 / 套管接箍光管本期收入数量;
            double f2 = 油管接箍光管本期收入金额 / 油管接箍光管本期收入数量;
            套管接箍光管本期结存金额 = f1 * 套管接箍光管本期结存数量;
            油管接箍光管本期结存金额 = f2 * 油管接箍光管本期结存数量;

            套管接箍投入数量 = double.Parse(套管接箍光管上期结存数量.ToString("0.000")) + double.Parse(套管接箍光管本期收入数量.ToString("0.000")) - double.Parse(套管接箍光管本期结存数量.ToString("0.000"));
            套管接箍投入金额 = double.Parse(套管接箍光管上期结存金额.ToString("0.00")) + double.Parse(套管接箍光管本期收入金额.ToString("0.00")) - double.Parse(套管接箍光管本期结存金额.ToString("0.00"));


            油管接箍投入数量 = double.Parse(油管接箍光管上期结存数量.ToString("0.000")) + double.Parse(油管接箍光管本期收入数量.ToString("0.000")) - double.Parse(油管接箍光管本期结存数量.ToString("0.000"));
            油管接箍投入金额 = double.Parse(油管接箍光管上期结存金额.ToString("0.00")) + double.Parse(油管接箍光管本期收入金额.ToString("0.00")) - double.Parse(油管接箍光管本期结存金额.ToString("0.00"));

        }
        Reader.Close();
        string sql6= @" declare @套管接箍回收金额 float
                        declare @油管接箍回收金额 float      
                                          
         select @套管接箍回收金额=-isnull(sum(回收金额),0) from 分厂废料回收金额 where 年度=@年度 and 月份=@月份 and 分厂ID=3 and 产品类别ID=4
         select @油管接箍回收金额=-isnull(sum(回收金额),0) from 分厂废料回收金额 where 年度=@年度 and 月份=@月份 and 分厂ID=3 and 产品类别ID=3
         select @套管接箍回收金额,@油管接箍回收金额                                              
                              ";
        sql6 = sql6.Replace("@年度", this.Year.Text);
        sql6= sql6.Replace("@月份", this.Month.Text);
        Cmd.CommandText = sql6;
         Reader = Cmd.ExecuteReader();

        if (Reader.Read())
        {
            套管接箍回收金额 = double.Parse(Reader[0].ToString());         
            油管接箍回收金额 = double.Parse(Reader[1].ToString());            
        }
        套管接箍本期入库金额 = 套管接箍投入金额 + 套管接箍回收金额 + 套管接箍费用;
        油管接箍本期入库金额 = 油管接箍投入金额 + 油管接箍回收金额 + 油管接箍费用;
        Reader.Close();

         string sql7 = @"
         declare @套管接箍本期转一分厂出库支数 float
         declare @套管接箍本期转二分厂出库支数 float            
         declare @油管接箍本期转二分厂出库支数 float 
         declare @油管接箍本期转五分厂出库支数 float

         select [dbo].[三分厂本期出库](@年度,@月份,2,1),[dbo].[三分厂本期出库](@年度,@月份,2,2),[dbo].[三分厂本期出库](@年度,@月份,1,2),[dbo].[三分厂本期出库](@年度,@月份,1,5)
         ";
         sql7 = sql7.Replace("@年度", this.Year.Text);
         sql7 = sql7.Replace("@月份", this.Month.Text);
         Cmd.CommandText = sql7;
         Reader = Cmd.ExecuteReader();

         if (Reader.Read())
         {
             套管接箍本期转一分厂出库支数 = double.Parse(Reader[0].ToString());
             套管接箍本期转二分厂出库支数 = double.Parse(Reader[1].ToString());
             油管接箍本期转二分厂出库支数 = double.Parse(Reader[2].ToString());
             油管接箍本期转五分厂出库支数 = double.Parse(Reader[3].ToString());
         }        
         Reader.Close();
         套管接箍本期转一分厂出库重量 = double.Parse((套管接箍本期转一分厂出库支数 * 6.1 / 1000).ToString("0.0000"));
         套管接箍本期转二分厂出库重量 = double.Parse((套管接箍本期转二分厂出库支数 * 6.1 / 1000).ToString("0.0000"));
         油管接箍本期转二分厂出库重量 = double.Parse((油管接箍本期转二分厂出库支数 * 2.3 / 1000).ToString("0.0000"));
         油管接箍本期转五分厂出库重量 = double.Parse((油管接箍本期转五分厂出库支数 * 2.3 / 1000).ToString("0.0000"));
        
         套管接箍本期转一分厂出库金额 = double.Parse((套管接箍本期转一分厂出库支数 * (套管接箍本期入库金额 / 套管接箍产量)).ToString("0.00"));
         套管接箍本期转二分厂出库金额 = double.Parse((套管接箍本期转二分厂出库支数 * (套管接箍本期入库金额 / 套管接箍产量)).ToString("0.00"));
         油管接箍本期转二分厂出库金额 = double.Parse((油管接箍本期转二分厂出库支数 * (油管接箍本期入库金额 / 套管接箍产量)).ToString("0.00"));
         油管接箍本期转五分厂出库金额 = double.Parse((油管接箍本期转五分厂出库支数 * (油管接箍本期入库金额 / 套管接箍产量)).ToString("0.00"));
        Cmd.Clone();
        Conn.Close();
    }
    protected void WriteToFile()
    {
        DateTime d;       
        d = DateTime.Today;       
        Response.ContentType = "application/ms-excel";
        Response.AddHeader("content-disposition", "attachment; filename=\"" + d.ToShortDateString() + ".xls\"");
        hssfworkbook.Write(Response.OutputStream);
    }

    protected void InitializeWorkbook()
    {

        FileStream file = new FileStream(HttpContext.Current.Server.MapPath("/ChengBen/三分厂/模板/半成品收发存表.xls"), FileMode.Open, FileAccess.Read);

        hssfworkbook = new HSSFWorkbook(file);

        DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
        dsi.Company = "陕西延长石油材料有限公司";
        hssfworkbook.DocumentSummaryInformation = dsi;

        SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
        si.Subject = "报表";
        si.Title = "三分厂半成品收发存表";
        hssfworkbook.SummaryInformation = si;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        InitializeWorkbook();
        HSSFSheet sheet1 = hssfworkbook.GetSheet("半成品收发存表");
        sheet1.GetRow(1).GetCell(0).SetCellValue(this.Year.Text+"年"+this.Month.Text+"月");
        Button_Query_Click(null, null);
        sheet1.GetRow(5).GetCell(5).SetCellValue(套管接箍产量);
        sheet1.GetRow(5).GetCell(6).SetCellValue(double.Parse((套管接箍产量 * 6.1 / 1000).ToString("0.0000")));
        sheet1.GetRow(5).GetCell(7).SetCellValue(套管接箍本期入库金额);

        sheet1.GetRow(8).GetCell(5).SetCellValue(套管接箍产量);
        sheet1.GetRow(8).GetCell(6).SetCellValue(double.Parse((套管接箍产量 * 6.1 / 1000).ToString("0.0000")));
        sheet1.GetRow(8).GetCell(7).SetCellValue(套管接箍本期入库金额);

        sheet1.GetRow(10).GetCell(5).SetCellValue(油管接箍产量);
        sheet1.GetRow(10).GetCell(6).SetCellValue(double.Parse((油管接箍产量 * 2.3 / 1000).ToString("0.0000")));
        sheet1.GetRow(10).GetCell(7).SetCellValue(油管接箍本期入库金额);

        sheet1.GetRow(13).GetCell(5).SetCellValue(油管接箍产量);
        sheet1.GetRow(13).GetCell(6).SetCellValue(double.Parse((油管接箍产量 * 2.3 / 1000).ToString("0.0000")));
        sheet1.GetRow(13).GetCell(7).SetCellValue(油管接箍本期入库金额);

        sheet1.GetRow(6).GetCell(8).SetCellValue(套管接箍本期转一分厂出库支数);
        sheet1.GetRow(6).GetCell(9).SetCellValue(套管接箍本期转一分厂出库重量);
        sheet1.GetRow(6).GetCell(10).SetCellValue(套管接箍本期转一分厂出库金额);
        
        sheet1.GetRow(7).GetCell(8).SetCellValue(套管接箍本期转二分厂出库支数);
        sheet1.GetRow(7).GetCell(9).SetCellValue(套管接箍本期转二分厂出库重量);
        sheet1.GetRow(7).GetCell(10).SetCellValue(套管接箍本期转二分厂出库金额);

        sheet1.GetRow(8).GetCell(8).SetCellValue(套管接箍本期转一分厂出库支数+套管接箍本期转二分厂出库支数);
        sheet1.GetRow(8).GetCell(9).SetCellValue(套管接箍本期转一分厂出库重量+套管接箍本期转二分厂出库重量);
        sheet1.GetRow(8).GetCell(10).SetCellValue(套管接箍本期转一分厂出库金额+套管接箍本期转二分厂出库金额);

        sheet1.GetRow(11).GetCell(8).SetCellValue(油管接箍本期转二分厂出库支数);
        sheet1.GetRow(11).GetCell(9).SetCellValue(油管接箍本期转二分厂出库重量);
        sheet1.GetRow(11).GetCell(10).SetCellValue(油管接箍本期转二分厂出库金额);

        sheet1.GetRow(12).GetCell(8).SetCellValue(油管接箍本期转五分厂出库支数);
        sheet1.GetRow(12).GetCell(9).SetCellValue(油管接箍本期转五分厂出库重量);
        sheet1.GetRow(12).GetCell(10).SetCellValue(油管接箍本期转五分厂出库金额);

        sheet1.GetRow(13).GetCell(8).SetCellValue(油管接箍本期转二分厂出库支数 + 油管接箍本期转五分厂出库支数);
        sheet1.GetRow(13).GetCell(9).SetCellValue(油管接箍本期转二分厂出库重量 + 油管接箍本期转五分厂出库重量);
        sheet1.GetRow(13).GetCell(10).SetCellValue(油管接箍本期转二分厂出库金额 + 油管接箍本期转五分厂出库金额);
        
        string op = (String)Session["OperatorName"];          
        sheet1.GetRow(14).GetCell(10).SetCellValue("制表："+op);
        WriteToFile();
        Response.End();
    }
 </script>
      <script type="text/javascript" language="javascript" src="/common.js"></script>
   <form id="form1" runat="server">  
      <div id="wintop" class="wintop"><span lang="zh-cn">三分厂费用归集分配表</span></div>
        <asp:Panel ID="Panel1" runat="server" CssClass="panel" Height="36px" >   
              年份：<asp:DropDownList ID="Year" runat="server">         
            <asp:ListItem>2010</asp:ListItem>
            <asp:ListItem>2011</asp:ListItem>
            <asp:ListItem>2012</asp:ListItem>
            <asp:ListItem>2013</asp:ListItem>
            <asp:ListItem>2014</asp:ListItem>
            <asp:ListItem>2015</asp:ListItem>   
            <asp:ListItem>2016</asp:ListItem>
            <asp:ListItem>2017</asp:ListItem>
            <asp:ListItem>2018</asp:ListItem>
            <asp:ListItem>2019</asp:ListItem>
            <asp:ListItem>2020</asp:ListItem>                
            </asp:DropDownList>
            <span lang="zh-cn">&nbsp;月份：</span><asp:DropDownList ID="Month" runat="server">
                <asp:ListItem>1</asp:ListItem>
                <asp:ListItem>2</asp:ListItem>
                <asp:ListItem>3</asp:ListItem>
                <asp:ListItem>4</asp:ListItem>
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>6</asp:ListItem>
                <asp:ListItem>7</asp:ListItem>
                <asp:ListItem>8</asp:ListItem>
                <asp:ListItem>9</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>11</asp:ListItem>
                <asp:ListItem>12</asp:ListItem>
            </asp:DropDownList>
      <span lang="zh-cn">&nbsp;&nbsp;</span><asp:Button ID="Button_Query"
            runat="server" Text="查看报表" CssClass="button" UseSubmitBehavior="true" onclick="Button_Query_Click" 
             />            
            &nbsp;<asp:Button ID="Button1" runat="server" class="button" onclick="Button1_Click" 
                Text="导 出" />
      </asp:Panel>
        <asp:Panel ID="Panel2" runat="server" CssClass="panel2">
        <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt" Visible="True"></asp:Label>
        </asp:Panel> 
     <div align="center">  
<style>
<!--table
	{mso-displayed-decimal-separator:"\.";
	mso-displayed-thousand-separator:"\,";}
@page
	{margin:1.0in .51in 1.0in .48in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-page-orientation:landscape;}
.font0
	{color:windowtext;
	font-size:12.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;}
tr
	{mso-height-source:auto;
	mso-ruby-visibility:none;}
col
	{mso-width-source:auto;
	mso-ruby-visibility:none;}
br
	{mso-data-placement:same-cell;}
.style0
	{mso-number-format:General;
	text-align:general;
	vertical-align:middle;
	white-space:nowrap;
	mso-rotate:0;
	mso-background-source:auto;
	mso-pattern:auto;
	color:windowtext;
	font-size:12.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;
	border:none;
	mso-protection:locked visible;
	mso-style-name:常规;
	mso-style-id:0;}
td
	{mso-style-parent:style0;
	padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:12.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;
	mso-number-format:General;
	text-align:general;
	vertical-align:middle;
	border:none;
	mso-background-source:auto;
	mso-pattern:auto;
	mso-protection:locked visible;
	white-space:nowrap;
	mso-rotate:0;}
.xl24
	{mso-style-parent:style0;
	text-align:center;
	border:.5pt solid windowtext;}
.xl25
	{mso-style-parent:style0;
	font-size:18.0pt;
	text-align:center;
	white-space:normal;}
.xl26
	{mso-style-parent:style0;
	font-size:18.0pt;
	text-align:center;}
.xl27
	{mso-style-parent:style0;
	text-align:center;}
.xl28
	{mso-style-parent:style0;
	text-align:center;
	border-top:.5pt solid windowtext;
	border-right:none;
	border-bottom:none;
	border-left:none;}
.xl29
	{mso-style-parent:style0;
	font-weight:700;
	text-align:center;
	border-top:.5pt solid windowtext;
	border-right:none;
	border-bottom:none;
	border-left:none;}
.xl30
	{mso-style-parent:style0;
	text-align:center;
	border:.5pt solid windowtext;
	white-space:normal;}
ruby
	{ruby-align:left;}
rt
	{color:windowtext;
	font-size:9.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;
	mso-char-type:none;
	display:none;}
-->
</style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>半成品收发存表</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:Print>
      <x:ValidPrinterInfo/>
      <x:PaperSizeIndex>9</x:PaperSizeIndex>
      <x:HorizontalResolution>600</x:HorizontalResolution>
      <x:VerticalResolution>600</x:VerticalResolution>
     </x:Print>
     <x:Selected/>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveRow>7</x:ActiveRow>
       <x:ActiveCol>4</x:ActiveCol>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet2</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet3</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:WindowHeight>10350</x:WindowHeight>
  <x:WindowWidth>14940</x:WindowWidth>
  <x:WindowTopX>360</x:WindowTopX>
  <x:WindowTopY>75</x:WindowTopY>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml><![endif]-->
</head>

<body link=blue vlink=purple>

<table x:str border=0 cellpadding=0 cellspacing=0 width=1020 style='border-collapse:
 collapse;table-layout:fixed;width:767pt'>
 <col width=72 span=2 style='width:54pt'>
 <col width=53 span=2 style='mso-width-source:userset;mso-width-alt:1696;
 width:40pt'>
 <col width=74 style='mso-width-source:userset;mso-width-alt:2368;width:56pt'>
 <col width=65 style='mso-width-source:userset;mso-width-alt:2080;width:49pt'>
 <col width=84 style='mso-width-source:userset;mso-width-alt:2688;width:63pt'>
 <col width=104 style='mso-width-source:userset;mso-width-alt:3328;width:78pt'>
 <col width=65 style='mso-width-source:userset;mso-width-alt:2080;width:49pt'>
 <col width=85 style='mso-width-source:userset;mso-width-alt:2720;width:64pt'>
 <col width=105 style='mso-width-source:userset;mso-width-alt:3360;width:79pt'>
 <col width=59 style='mso-width-source:userset;mso-width-alt:1888;width:44pt'>
 <col width=57 style='mso-width-source:userset;mso-width-alt:1824;width:43pt'>
 <col width=72 style='width:54pt'>
 <tr height=33 style='mso-height-source:userset;height:24.75pt'>
  <td colspan=14 height=33 class=xl25 width=1020 style='height:24.75pt;
  width:767pt'>三分厂产品成本计算表</td>
 </tr>
 <tr height=25 style='mso-height-source:userset;height:18.75pt'>
  <td colspan=14 height=25 class=xl27 style='height:18.75pt'><%=this.Year.Text %>年<span
  style='mso-spacerun:yes'></span><%=this.Month.Text %>月</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td rowspan=2 height=77 class=xl24 style='height:57.95pt'>项目</td>
  <td rowspan=2 class=xl24>摘要</td>
  <td colspan=3 class=xl24 style='border-left:none'>期初</td>
  <td colspan=3 class=xl24 style='border-left:none'>本期入库</td>
  <td colspan=3 class=xl24 style='border-left:none'>本期出库</td>
  <td colspan=3 class=xl24 style='border-left:none'>结存</td>
 </tr>
 <tr height=44 style='mso-height-source:userset;height:33.0pt'>
  <td height=44 class=xl30 width=53 style='height:33.0pt;border-top:none;
  border-left:none;width:40pt'>数量<br>
    (支)</td>
  <td class=xl30 width=53 style='border-top:none;border-left:none;width:40pt'>重量<br>
    (吨)</td>
  <td class=xl24 style='border-top:none;border-left:none'>金额</td>
  <td class=xl30 width=65 style='border-top:none;border-left:none;width:49pt'>数量<br>
    (支)</td>
  <td class=xl30 width=84 style='border-top:none;border-left:none;width:63pt'>重量<br>
    (吨)</td>
  <td class=xl24 style='border-top:none;border-left:none'>金额</td>
  <td class=xl30 width=65 style='border-top:none;border-left:none;width:49pt'>数量<br>
    (支)</td>
  <td class=xl30 width=85 style='border-top:none;border-left:none;width:64pt'>重量<br>
    (吨)</td>
  <td class=xl24 style='border-top:none;border-left:none'>金额</td>
  <td class=xl30 width=59 style='border-top:none;border-left:none;width:44pt'>数量<br>
    (支)</td>
  <td class=xl30 width=57 style='border-top:none;border-left:none;width:43pt'>重量<br>
    (吨)</td>
  <td class=xl24 style='border-top:none;border-left:none'>金额</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td rowspan=5 height=132 class=xl24 style='height:99.8pt;border-top:none'>套管接箍</td>
  <td class=xl24 style='border-top:none;border-left:none'>上期结存</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td height=33 class=xl24 style='height:24.95pt;border-top:none;border-left:
  none'>本期入库</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍产量 %></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=double.Parse((套管接箍产量*6.1/1000).ToString("0.0000")) %></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期入库金额 %></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td height=33 class=xl24 style='height:24.95pt;border-top:none;border-left:
  none'>转一分厂</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转一分厂出库支数%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转一分厂出库重量%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转一分厂出库金额%></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td height=33 class=xl24 style='height:24.95pt;border-top:none;border-left:
  none'>转二分厂</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转二分厂出库支数%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转二分厂出库重量%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转二分厂出库金额%></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
  <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td  height=33 class=xl24 style='height:24.95pt;border-top:none;'>本月合计</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍产量 %></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=double.Parse((套管接箍产量*6.1/1000).ToString("0.0000")) %></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期入库金额 %></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转一分厂出库支数+套管接箍本期转二分厂出库支数%>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转一分厂出库重量 + 套管接箍本期转二分厂出库重量%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=套管接箍本期转一分厂出库金额+套管接箍本期转二分厂出库金额%></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td rowspan=5 height=132 class=xl24 style='height:99.8pt;border-top:none'>油管接箍</td>
  <td class=xl24 style='border-top:none;border-left:none'>上期结存</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td height=33 class=xl24 style='height:24.95pt;border-top:none;border-left:
  none'>本期入库</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍产量 %></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=double.Parse((油管接箍产量 * 2.3 / 1000).ToString("0.0000"))%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期入库金额 %></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td height=33 class=xl24 style='height:24.95pt;border-top:none;border-left:
  none'>转二分厂</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转二分厂出库支数%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转二分厂出库重量%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转二分厂出库金额%></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td height=33 class=xl24 style='height:24.95pt;border-top:none;border-left:
  none'>转五分厂</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转五分厂出库支数%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转五分厂出库重量%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转五分厂出库金额%></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=33 style='mso-height-source:userset;height:24.95pt'>
  <td height=33 class=xl24 style='height:24.95pt;border-top:none;'>本月合计</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍产量 %>　</td>
  <td class=xl24 style='border-top:none;border-left:none'><%=double.Parse((油管接箍产量 * 2.3 / 1000).ToString("0.0000"))%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期入库金额 %></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转二分厂出库支数+油管接箍本期转五分厂出库支数%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转二分厂出库重量 + 油管接箍本期转五分厂出库重量%></td>
  <td class=xl24 style='border-top:none;border-left:none'><%=油管接箍本期转二分厂出库金额 + 油管接箍本期转五分厂出库金额%></td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
  <td class=xl24 style='border-top:none;border-left:none'>　</td>
 </tr>
 <tr height=38 style='mso-height-source:userset;height:28.5pt'>
  <td height=38 style='height:28.5pt'></td>
  <td colspan=3 class=xl28>单位负责人:<font class="font0">魏 君</font></td>
  <td colspan=6 style='mso-ignore:colspan'></td>
  <td colspan=3 class=xl28>制表：<%=(String)Session["OperatorName"] %></td>
  <td></td>
 </tr>
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=72 style='width:54pt'></td>
  <td width=72 style='width:54pt'></td>
  <td width=53 style='width:40pt'></td>
  <td width=53 style='width:40pt'></td>
  <td width=74 style='width:56pt'></td>
  <td width=65 style='width:49pt'></td>
  <td width=84 style='width:63pt'></td>
  <td width=104 style='width:78pt'></td>
  <td width=65 style='width:49pt'></td>
  <td width=85 style='width:64pt'></td>
  <td width=105 style='width:79pt'></td>
  <td width=59 style='width:44pt'></td>
  <td width=57 style='width:43pt'></td>
  <td width=72 style='width:54pt'></td>
 </tr>
 <![endif]>
</table>
    
    </div>
    </form>
</body>
</html>
